<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
    <% String path=request.getContextPath(); String basePath=request.getScheme() + "://" + request.getServerName() + ":"
        + request.getServerPort() + path + "/" ; %>

        <!DOCTYPE html>
        <html>

        <head>
            <base href="<%=basePath%>">

            <title>报价揭示</title>

            <meta http-equiv="pragma" content="no-cache">
            <meta http-equiv="cache-control" content="no-cache">
            <meta http-equiv="expires" content="0">
            <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
            <meta http-equiv="description" content="This is my page">
            <!--
                    <link rel="stylesheet" type="text/css" href="styles.css">
                    -->
        </head>
        <style>
            .tdText {
                text-align: right;
                width: 400px;
            }

            input:disabled {
                background-color: #dae1ed;
            }
        </style>

        <body>
            <%@ include file="/WEB-INF/jsp/common/header.jsp" %>
                <%@ include file="/WEB-INF/jsp/common/loadDiv.jsp" %>

                    <script type="text/javascript">
                        $(function () {
                            $('#startTime').datebox('setValue', getBeforeCurrentDate90Days());
                            $('#endTime').datebox('setValue', getNowFormatDate());
                            bingGrid();
                        });

                    </script>

                    <div class="query_criteria" id="query_criteria">
                        <div style="margin: 5px 0px">
                            <label style="font-size: 12px;">创建时间：</label> <input class="easyui-datebox" name="startTime"
                                id="startTime"
                                data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                value="" style="width: 150px"> <label style="font-size: 10px;">~</label> <input
                                class="easyui-datebox" name="endTime" id="endTime"
                                data-options="required:true,showSeconds:false,formatter:myformatter,parser:myparser"
                                style="width: 150px" /> <label style="margin-left: 20px; font-size: 12px;">状态：</label>
                            <input class="easyui-combobox" id="status" name="status" style="width: 80px;" data-options="valueField: 'value',editable:false,
		textField: 'label',panelHeight:'auto',data: [{
			label: '全部',
			value: ''
		},{
			label: '待揭示',
			value: '0',
			'selected':true
		},{
			label: '已揭示',
			value: '1'
		},{
			label: '已完成',
			value: '2'
		}]">
                            <a id="search" href="javascript:void(0)" class="easyui-linkbutton"
                                data-options="iconCls:'icon-search'" onclick="selectRevealList()">查询</a>
                        </div>
                        <table id="tt"></table>
                        <%--修改报价时间的弹窗 --%>
                            <div id="updateTimeWindow" class="easyui-window" maximizable="false" minimizable="false"
                                collapsible="false" closed="true" modal="true" title="询价书"
                                style="width: 900px; height: 200px; padding: 5px 5px">
                                <table>
                                    <tr style="margin-bottom: 10px">
                                        <td colspan="1" class="tdText"><input type="hidden" id="updaeByInqId"> <label
                                                style="width: 40%; text-align: right;">报价开始时间：</label> <input
                                                id="offerStartTime" class="easyui-datetimebox"
                                                data-options="required:true,showSeconds:false,formatter:myformatterDateTime,parser:myparserDateTime"
                                                value="" style="width: 150px" style="width: 60%"></td>
                                        <td class="tdText"><label style="width: 40%; text-align: right;">报价结束时间：</label>
                                            <input id="offerEndTime" class="easyui-datetimebox"
                                                data-options="required:true,showSeconds:false,formatter:myformatterDateTime,parser:myparserDateTime"
                                                value="" style="width: 150px" style="width: 60%">
                                        </td>
                                        <td class="tdText"><label style="width: 40%; text-align: right;">报价揭示时间：</label>
                                            <input id="offerRevealTime" class="easyui-datetimebox"
                                                data-options="required:true,showSeconds:false,formatter:myformatterDateTime,parser:myparserDateTime"
                                                value="" style="width: 150px" style="width: 60%">
                                        </td>
                                    </tr>
                                </table>
                                <div data-options="region:'south',border:false"
                                    style="text-align: center; padding: 10px 0 0;">
                                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'"
                                        href="javascript:void(0)" onclick="$('#updateTimeWindow').window('close')"
                                        style="width: 80px">取消</a>
                                    <a class="easyui-linkbutton" data-options="iconCls:'icon-save'"
                                        href="javascript:void(0)" onclick="updateTime()" style="width: 80px">保存</a>
                                </div>
                            </div>
                            <%--竞价跟进的弹窗 --%>
                                <div id="updateLowStatusWindow" class="easyui-window" maximizable="false"
                                    minimizable="false" collapsible="false" closed="true" modal="true" title="询价书"
                                    style="width: 700px; height: 200px; padding: 5px 5px">
                                    <table>
                                        <tr style="margin-bottom: 10px">
                                            <td class="tdText"><label
                                                    style="width: 40%; text-align: right;">竞价结束时间：</label>
                                                <input id="lowStatusTime" class="easyui-datetimebox"
                                                    data-options="required:true,showSeconds:false,formatter:myformatterDateTime,parser:myparserDateTime"
                                                    value="" style="width: 150px" style="width: 60%">
                                            </td>
                                        </tr>
                                    </table>
                                    <div data-options="region:'south',border:false"
                                        style="text-align: center; padding: 10px 0 0;">
                                        <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'"
                                            href="javascript:void(0)"
                                            onclick="$('#updateLowStatusWindow').window('close')"
                                            style="width: 80px">取消</a>
                                        <a class="easyui-linkbutton" data-options="iconCls:'icon-save'"
                                            href="javascript:void(0)" onclick="updateLowStatus()"
                                            style="width: 80px">保存</a>
                                    </div>
                                </div>
                    </div>
                    <div id="add" class="easyui-window" closed="true" modal="true" title="报价状态"
                        style="width: 900px; height: 400px; padding: 10px 20px; top: 50px">
                        <table id="suppliesOffer"></table>
                    </div>
                    <div id="addAllRankWindow" class="easyui-window" closed="true" modal="true" title="报价结果"
                        style="width: 900px; height: 400px; padding: 10px 20px; top: 50px">
                        <table id="allRankTT"></table>
                    </div>
                    <div id="addDetailRankWindow" class="easyui-window" closed="true" modal="true" title="单价排名"
                        style="width: 900px; height: 400px; padding: 10px 20px; top: 50px">
                        <table id="detailRankTT"></table>
                    </div>
                    <div id="recordMmWindow" class="easyui-window" closed="true" modal="true" title="报价明细"
                        style="width: 900px; height: 400px; padding: 5px 5px">
                        <table id="recordMmTT"></table>
                    </div>
                    <div id="recordCompeteWindow" class="easyui-window" closed="true" modal="true" title="竞价记录"
                        style="width: 900px; height: 400px; padding: 5px 5px">
                        <table id="recordCompeteTT"></table>
                    </div>
                    <div id="competeMmWindow" class="easyui-window" closed="true" modal="true" title="竞价明细"
                        style="width: 900px; height: 400px; padding: 5px 5px">
                        <table id="competeMmTT"></table>
                    </div>
        </body>
        <script type="text/javascript">
            /**
             *  报价揭示
             */
            function offerReveal() {
                let dg = $('#tt');
                let row = dg.datagrid('getSelected');
                if (!row) {
                    $.messager.alert('提示', '请选择一条数据');
                    return
                }
                let today = getNowFormatTime();
                if (today < row.inqRevealTime) {
                    $.messager.alert('提示', '未到报价揭示日期，无法揭示报价');
                    return
                }
                if (+row.inqRevealStatus == '1') {
                    $.messager.alert('提示', '该询价书已揭示报价');
                    return
                }
                $.ajax({
                    type: 'get',
                    url: 'purchase/reveal/revealInquiry?inqId=' + row.inqId,
                    success: function (data) {
                        if (data.code != 60200) {
                            $.messager.alert('消息', data.msg);
                        } else {
                            $.messager.alert('消息', data.msg);
                            selectRevealList()
                            /*let dg = $('#tt');
                            dg.datagrid('enableFilter');
                            dg.datagrid('load');*/
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.messager.alert('消息', errorThrown);
                    }
                })
            }

            /**
             *  报价揭示撤回
             */
            function backReveal() {
                let dg = $('#tt');
                let row = dg.datagrid('getSelected');
                if (!row) {
                    $.messager.alert('提示', '请选择一条数据');
                    return
                }
                $.ajax({
                    type: 'get',
                    url: 'purchase/reveal/backReveal?inqId=' + row.inqId,
                    success: function (data) {
                        if (data.code != 60200) {
                            $.messager.alert('消息', data.msg);
                        } else {
                            $.messager.alert('消息', data.msg);
                            selectRevealList()
                            /*let dg = $('#tt');
                            dg.datagrid('enableFilter');
                            dg.datagrid('load');*/
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.messager.alert('消息', errorThrown);
                    }
                })
            }


            /**
             *查看供应商报价状态
             */
            function suppliesOfferStatus(index) {
                const rows = $('#tt').datagrid('getRows');
                let row = rows[index];
                $('#add').window('open');
                bingSupplyGrid(row);
            }

            //查询询价书
            function selectRevealList() {
                let startTime = $('#startTime').datebox('getValue');
                let endTime = $('#endTime').datebox('getValue');
                let status = $('#status').combobox('getValue');
                let dg = $('#tt');
                dg.datagrid('enableFilter');
                dg.datagrid('load', {
                    startTime: startTime ? startTime : '',
                    endTime: endTime ? endTime : '',
                    inqRevealStatus: status ? status : '',
                    status: '1'
                })
            }

            //修改最低价状态
            function updateLowStatus() {
                let row = $('#tt').datagrid('getSelected');
                if (!row) {
                    $.messager.alert('提示', '请选择一条数据');
                    return
                }
                if (+row.inqRevealStatus != '1') {
                    $.messager.alert('提示', '只能在已揭示状态操作！');
                    return
                }
                let endTime = $('#lowStatusTime').datetimebox('getValue');

                $.messager.confirm('提示', '确定要竞价跟进吗?',
                    function (r) {
                        if (r) {
                            $.ajax({
                                type: 'get',
                                url: 'purchase/reveal/updateLowStatus?inqId=' + row.inqId + '&endTime=' + endTime,
                                success: function (data) {
                                    $.messager.alert('消息', data.msg);
                                },
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    $.messager.alert('消息', errorThrown);
                                }
                            })
                        }
                    })
            }

            function openStatusWindow() {
                let row = $('#tt').datagrid('getSelected');
                if (!row) {
                    $.messager.alert('提示', '请选择一条数据');
                    return
                }

                if (+row.inqRevealStatus != '1') {
                    $.messager.alert('提示', '只有已揭示状态可操作！');
                    return
                }
                $('#updateLowStatusWindow').window('open')
            }

            /**
             * 修改报价时间
             */
            function openUpdateInquiryDateWindow() {
                let row = $('#tt').datagrid('getSelected');
                if (!row) {
                    $.messager.alert('提示', '请选择一条数据');
                    return
                }

                if (+row.inqRevealStatus == '1') {
                    $.messager.alert('提示', '该询价书已揭示报价');
                    return
                }
                $('#updaeByInqId').val(row.inqId)
                $('#offerStartTime').datetimebox('setValue', row.inqStartTime)
                $('#offerEndTime').datetimebox('setValue', row.inqEndTime)
                $('#offerRevealTime').datetimebox('setValue', row.inqRevealTime)
                $('#updateTimeWindow').window('open')
            }

            /**
             * 保存修改时间
             */
            function updateTime() {
                let startTime = $('#offerStartTime').datetimebox('getValue');
                let endTime = $('#offerEndTime').datetimebox('getValue');
                let revealTime = $('#offerRevealTime').datetimebox('getValue');
                let inqId = $('#updaeByInqId').val();
                if (!startTime || !endTime || !inqId) {
                    $.messager.alert('提示', '请输入开始时间或结束时间');
                    return
                }

                $.ajax({
                    type: 'get',
                    url: 'purchase/reveal/updateInquiry?inqId=' + inqId + '&startTime=' + startTime + '&endTime=' +
                        endTime + '&revealTime=' + revealTime,
                    success: function (data) {
                        if (data.code != 60200) {
                            $.messager.alert('消息', data.msg);
                        } else {
                            $('#updateTimeWindow').window('close')
                            let dg = $('#tt');
                            dg.datagrid('enableFilter');
                            dg.datagrid('load');
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.messager.alert('消息', errorThrown);
                    }
                })
            }

            function bingSupplyGrid(row) {
                let dg = $('#suppliesOffer');
                dg.datagrid({
                    title: '报价状态',
                    url: 'purchase/offer/selectOfferList',
                    queryParams: {
                        inqId: row.inqId,
                    },
                    iconCls: 'icon-application',
                    clientPaging: false,
                    remoteFilter: true,
                    filterDelay: 0,
                    width: 800,
                    height: 300,
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    columns: [
                        [{
                            field: 'infCode',
                            title: '供应商编码',
                            width: 100,
                            formatter: function (val, rec) {
                                return unescape(val)
                            }
                        }, {
                            field: 'infName',
                            title: '供应商名称',
                            width: 260,
                            formatter: function (val, rec) {
                                return unescape(val)
                            }
                        },
                        {
                            field: 'inqOfrTime',
                            title: '完成时间',
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        ]
                    ],

                })
            }
        </script>
        <script>
            function viewRankAll(index) {
                const rows = $('#tt').datagrid('getRows');
                let row = rows[index];
                if (row.inqRevealStatus == 0) {
                    $.messager.alert('提示', '揭示后可查看！');
                    return;
                }
                $('#addAllRankWindow').window('open');
                bindRankAllGrid(row);
            }
            function bindRankAllGrid(row) {
                let dg = $('#allRankTT');
                dg.datagrid({
                    title: '报价结果',
                    url: 'purchase/offer/selectOfferList',
                    queryParams: {
                        inqId: row.inqId,
                        sortMode: row.inqDealMode
                    },
                    iconCls: 'icon-application',
                    clientPaging: false,
                    remoteFilter: true,
                    filterDelay: 0,
                    width: 800,
                    height: 300,
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    columns: [
                        [{
                            field: 'infCode',
                            title: '供应商编码',
                            width: 100,
                            formatter: function (val, rec) {
                                return unescape(val)
                            }
                        }, {
                            field: 'infName',
                            title: '供应商名称',
                            width: 260,
                            formatter: function (val, rec) {
                                return unescape(val)
                            }
                        },
                        {
                            field: 'inqOfrTotalPrice',
                            title: '合计金额',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqOfrNum',
                            title: '合计数量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'unit',
                            title: '单价',
                            formatter: function (val, rec) {
                                var unit = Math.round(rec.inqOfrTotalPrice / rec.inqOfrNum, 2);
                                return unit
                            }
                        },
                        {
                            field: 'inqOfrTime',
                            title: '完成时间',
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'bjmx',
                            title: '',
                            width: 80,
                            formatter: function (val, rec, index) {
                                return '<a href="javascript:void(0)" onclick="openOfferMmDetail(' + index +
                                    ')">' + ('报价明细') + '</a>'
                            }
                        }
                        ]
                    ],

                })
            }

            function openOfferMmDetail(index) {
                let dg = $('#allRankTT')
                const rows = dg.datagrid('getRows')
                let row = rows[index]
                $('#recordMmWindow').window('open');
                bingRecordMmGrid(row)
            }

            function bingRecordMmGrid(row) {
                let dg = $('#recordMmTT');
                dg.datagrid({
                    title: '',
                    queryParams: {
                        inqId: row.inqId,
                        infId: row.infId
                    },
                    fitColumns: false,
                    fit: false,
                    url: 'purchase/offer/selectOfferMmList',
                    iconCls: 'icon-application',
                    clientPaging: false,
                    // remoteFilter: true,
                    filterDelay: 0,
                    width: 850,
                    height: 350,
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    pageSize: 10,
                    remoteSort: false,
                    pagination: true,
                    frozenColumns: [[
                        {
                            field: 'mmCode',
                            title: '物资编码',
                            width: 120,
                            formatter: function (val, rec, index) {
                                return val ? val : '';
                            }
                        },
                        {
                            field: 'mmDetail',
                            title: '物资描述',
                            formatter: function (val, rec, index) {
                                if (val) {
                                    return '<span title="' + val + '">' + val + '</span>';
                                } else {
                                    return val;
                                }
                            }
                        },
                        {
                            field: 'rank',
                            title: '单价排名',
                            formatter: function (val, rec, index) {
                                return val ? val : '';
                            }
                        },
                    ]],
                    columns: [[
                        {
                            field: 'mmUnit',
                            title: '计量单位',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'mmUnitDetail',
                            title: '计量单位描述',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'gramPurNum',
                            title: '招标数量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqOfrTotalPrice',
                            title: '合计价格',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqOfrNum',
                            title: '报价数量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqOfrUnitPrice',
                            title: '报价单价',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqTaxNum',
                            title: '税码',
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'gramUseName',
                            title: '使用人姓名',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'gramUseTel',
                            title: '使用人联系方式',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqDeliverDate',
                            title: '交货日期',
                            sortable: true,
                            width: 120,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'remark',
                            title: '备注',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqOfrTime',
                            title: '提交时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'createTime',
                            title: '创建时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                    ]],
                    onLoadSuccess: function () {

                    },
                    onDblClickRow: function (rowIndex, rowData) {
                    }

                });
                // dg.datagrid('enableFilter');
            }

            function viewRankDetail(index) {
                const rows = $('#tt').datagrid('getRows');
                let row = rows[index];
                if (row.inqRevealStatus == 0) {
                    $.messager.alert('提示', '揭示后可查看！');
                    return;
                }
                $.ajax({
                    type: "get",
                    url: 'purchase/reveal/selectRankMmList?inqId=' + row.inqId,
                    success: function (data) {
                        if (data.code == 60200) {
                            $('#addDetailRankWindow').window('open');
                            bindRankDetailGrid(data.data);
                        }
                    },
                    error: function (XMLHttpRequest, textStatus,
                        errorThrown) {
                        $.messager.alert('消息', errorThrown);
                    }
                });
            }

            function bindRankDetailGrid(rows) {
                let dg = $('#detailRankTT');
                dg.datagrid({
                    title: '',
                    // url: 'purchase/offer/selectOfferMmRankList',
                    data: rows.rows,
                    // queryParams: {
                    //     inqId: row.inqId,
                    //     sort: '`rank`'
                    // },
                    iconCls: 'icon-application',
                    clientPaging: false,
                    remoteFilter: true,
                    filterDelay: 0,
                    width: 800,
                    height: 300,
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    frozenColumns: [rows.froColumnsModels],
                    columns: [rows.columnsModels],
                    // toolbar: [{
                    //     text: '刷新',
                    //     iconCls: 'icon-reload',
                    //     handler: function () { 
                    //         $('#detailRankTT').datagrid('reload');
                    //         viewRankDetail();
                    //     }
                    // }]
                })
            }
        </script>

        <script>
            function viewCompeteRecord(index) {
                const rows = $('#tt').datagrid('getRows');
                let row = rows[index];
                if (row.inqRevealStatus == 0) {
                    $.messager.alert('提示', '揭示后可查看！');
                    return;
                }
                if (row.inqOfferMode != '竞价') {
                    $.messager.alert('提示', '竞价模式可查看！');
                    return;
                }
                $('#recordCompeteWindow').window('open');
                bindCompeteGrid(row);
            }
            function bindCompeteGrid(row) {
                let dg = $('#recordCompeteTT');
                dg.datagrid({
                    title: '',
                    url: 'purchase/compete/record/selectList',
                    queryParams: {
                        inqId: row.inqId
                    },
                    iconCls: 'icon-application',
                    clientPaging: false,
                    remoteFilter: true,
                    filterDelay: 0,
                    width: 800,
                    height: 300,
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    columns: [
                        [{
                            field: 'infCode',
                            title: '供应商编码',
                            width: 100,
                            formatter: function (val, rec) {
                                return unescape(val)
                            }
                        }, {
                            field: 'infName',
                            title: '供应商名称',
                            width: 260,
                            formatter: function (val, rec) {
                                return unescape(val)
                            }
                        },
                        {
                            field: 'inqOfrTotalPrice',
                            title: '合计金额',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqOfrNum',
                            title: '合计数量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'unit',
                            title: '单价',
                            formatter: function (val, rec) {
                                var unit = Math.round(rec.inqOfrTotalPrice / rec.inqOfrNum, 2);
                                return unit
                            }
                        },
                        {
                            field: 'inqOfrTime',
                            title: '提交时间',
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'bjmx',
                            title: '',
                            width: 80,
                            formatter: function (val, rec, index) {
                                return '<a href="javascript:void(0)" onclick="openCompeteMmDetail(' + index +
                                    ')">' + ('竞价明细') + '</a>'
                            }
                        }
                            // {
                            //     field: 'rank',
                            //     title: '排名',
                            //     formatter: function (val, rec) {
                            //         return unescape(val ? val : '')
                            //     }
                            // },
                        ]
                    ],

                })
            }


            function openCompeteMmDetail(index) {
                let dg = $('#recordCompeteTT')
                const rows = dg.datagrid('getRows')
                let row = rows[index]
                $('#competeMmWindow').window('open');
                bingcompeteMmGrid(row)
            }

            function bingcompeteMmGrid(row) {
                let dg = $('#competeMmTT');
                dg.datagrid({
                    title: '',
                    queryParams: {
                        inqId: row.inqId,
                        infId: row.infId,
                        comUuid: row.comUuid
                    },
                    fitColumns: false,
                    fit: false,
                    url: 'purchase/compete/record/mm/selectList',
                    iconCls: 'icon-application',
                    clientPaging: false,
                    // remoteFilter: true,
                    filterDelay: 0,
                    width: 850,
                    height: 350,
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    pageSize: 10,
                    remoteSort: false,
                    pagination: true,
                    frozenColumns: [[
                        {
                            field: 'mmCode',
                            title: '物资编码',
                            width: 120,
                            formatter: function (val, rec, index) {
                                return val ? val : '';
                            }
                        },
                        {
                            field: 'mmDetail',
                            title: '物资描述',
                            formatter: function (val, rec, index) {
                                if (val) {
                                    return '<span title="' + val + '">' + val + '</span>';
                                } else {
                                    return val;
                                }
                            }
                        },
                        // {
                        //     field: 'rank',
                        //     title: '单价排名',
                        //     formatter: function (val, rec, index) {
                        //         return val ? val : '';
                        //     }
                        // },
                    ]],
                    columns: [[
                        {
                            field: 'mmUnit',
                            title: '计量单位',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'mmUnitDetail',
                            title: '计量单位描述',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'gramPurNum',
                            title: '招标数量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqOfrTotalPrice',
                            title: '合计价格',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqOfrNum',
                            title: '报价数量',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqOfrUnitPrice',
                            title: '报价单价',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'inqTaxNum',
                            title: '税码',
                            formatter: function (val, rec) {
                                return unescape(val ? val : 0)
                            }
                        },
                        {
                            field: 'gramUseName',
                            title: '使用人姓名',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'gramUseTel',
                            title: '使用人联系方式',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqDeliverDate',
                            title: '交货日期',
                            sortable: true,
                            width: 120,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'remark',
                            title: '备注',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqOfrTime',
                            title: '提交时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'createTime',
                            title: '创建时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                    ]],
                    onLoadSuccess: function () {

                    },
                    onDblClickRow: function (rowIndex, rowData) {
                    }

                });
                // dg.datagrid('enableFilter');
            }

        </script>

        <script>
            function bingGrid() {
                let startTime = $('#startTime').datebox('getValue');
                let endTime = $('#endTime').datebox('getValue');
                let status = $('#status').combobox('getValue');
                let dg = $('#tt');
                dg.datagrid({
                    title: '',
                    url: 'purchase/selectInquiryList',
                    queryParams: {
                        startTime: startTime ? startTime : '',
                        endTime: endTime ? endTime : '',
                        inqRevealStatus: status ? status : '',
                        status: '1'
                    },
                    iconCls: 'icon-application',
                    clientPaging: false,
                    remoteFilter: true,
                    filterDelay: 0,
                    width: getWidth(0.98),
                    height: 400,
                    nowrap: true,
                    rownumbers: true,
                    animate: false,
                    collapsible: false,
                    singleSelect: true,
                    pageSize: 10,
                    remoteSort: true,
                    pagination: true,
                    frozenColumns: [
                        [
                            {
                                field: 'inqCode',
                                title: '询价编码',
                                sortable: true,
                                formatter: function (val, rec) {
                                    return unescape(val ? val : '')
                                }
                            },
                            {
                                field: 'inqName',
                                title: '询价名称',
                                sortable: true,
                                formatter: function (val, rec, index) {
                                    return unescape(val ? val : '')
                                }
                            },
                        ]
                    ],
                    columns: [
                        [{
                            field: 'inqId',
                            title: '询价书ID',
                            hidden: true,
                            sortable: true,
                            width: 100,
                            formatter: function (val, rec) {
                                return unescape(val)
                            }
                        },
                        {
                            field: 'gramName',
                            title: '采购方案名称',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqOfferMode',
                            title: '报价方式',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqDealMode',
                            title: '成交方式',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqStartTime',
                            title: '报价开始时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqEndTime',
                            title: '报价结束时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqRevealTime',
                            title: '报价揭示时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'inqActualTime',
                            title: '实际揭示时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        // {
                        //     field: 'inqClause',
                        //     title: '价格条款',
                        //     sortable: true,
                        //     formatter: function (val, rec) {
                        //         return unescape(val ? val : '')
                        //     }
                        // },
                        // {
                        //     field: 'inqDetail',
                        //     title: '相关说明',
                        //     sortable: true,
                        //     formatter: function (val, rec) {
                        //         return unescape(val ? val : '')
                        //     }
                        // },
                        {
                            field: 'inqActualName',
                            title: '揭示人姓名',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        {
                            field: 'createTime',
                            title: '创建时间',
                            sortable: true,
                            formatter: function (val, rec) {
                                return unescape(val ? val : '')
                            }
                        },
                        // {
                        //     field: 'updateTime',
                        //     title: '更新时间',
                        //     sortable: true,
                        //     formatter: function (val, rec) {
                        //         return unescape(val ? val : '')
                        //     }
                        // },
                        {
                            field: 'inqRevealStatus',
                            title: '状态',
                            //                             op: ['less', 'greater'],
                            //sortable : true,
                            formatter: function (val, rec) {
                                return unescape(val == '1' ? '已揭示' : (val == '2' ? '已完成' : '待揭示'))
                            }
                        }, {
                            field: 'ofrStaus',
                            title: '',
                            width: 80,
                            formatter: function (val, rec, index) {
                                return '<a href="javascript:void(0)" onclick="suppliesOfferStatus(' + index +
                                    ')">报价状态</a>'

                            }
                        }, {
                            field: 'rankAll',
                            title: '',
                            width: 80,
                            formatter: function (val, rec, index) {
                                return '<a href="javascript:void(0)" onclick="viewRankAll(' + index +
                                    ')">报价结果</a>'
                            }
                        }, {
                            field: 'rankDetail',
                            title: '',
                            width: 80,
                            formatter: function (val, rec, index) {
                                return '<a href="javascript:void(0)" onclick="viewRankDetail(' + index +
                                    ')">汇总展示</a>'
                            }
                        }, {
                            field: 'competeRecord',
                            title: '',
                            width: 80,
                            formatter: function (val, rec, index) {
                                return '<a href="javascript:void(0)" onclick="viewCompeteRecord(' + index +
                                    ')">竞价记录</a>'
                            }
                        },
                        ]
                    ],
                    toolbar: [{
                        text: '报价揭示',
                        iconCls: 'icon-add',
                        handler: function () {
                            let row = dg.datagrid('getSelected');
                            if (!row) {
                                $.messager.alert('提示', '请选择一条数据');
                                return
                            } else {
                                $.messager.confirm('提示', '确定要揭示吗?',
                                    function (r) {
                                        if (r) {
                                            offerReveal();
                                        }
                                    });
                            }
                        }
                    },
                        '-',
                    {
                        text: '修改报价时间',
                        iconCls: 'icon-edit',
                        handler: function () {
                            openUpdateInquiryDateWindow();
                        }
                    },
                        '-',
                    {
                        text: '撤回',
                        iconCls: 'icon-undo',
                        handler: function () {
                            let row = $('#tt').datagrid('getSelected');
                            if (!row) {
                                $.messager.alert('提示', '请选择一条数据');
                                return
                            }
                            if (row.inqRevealStatus == '0') {
                                $.messager.alert('提示', '该单据未提交，无法撤回')
                                return
                            }
                            $.messager.confirm('提示', '系统会自动保存撤回记录，确定要撤回吗?',
                                function (r) {
                                    if (r) {
                                        backReveal();
                                    }
                                });
                        }
                    }, '-',
                    {
                        text: '竞价跟进',
                        iconCls: 'icon-edit',
                        handler: function () {
                            openStatusWindow();
                        }
                    },
                    ],
                    onLoadSuccess: function () {
                    },
                    onDblClickRow: function () {

                    }
                });

                dg.datagrid('enableFilter');
            }
        </script>

        </html>